//6.编写一个程序，接受用户输入的一个字符串，并输出该字符串中出现频率最高的字符。

#include <stdio.h>
#include <string.h>

#define BUFFER_SIZE 200

int findMostFreqChar(char *str)
{
    int count[BUFFER_SIZE] = {};
    int len = strlen(str);
    for (int idx = 0; idx <= len; idx++)
    {
        count[str[idx]]++;
    }

    char mostFreqChar = '\0';
    int maxCount = 0;

    for (int jdx = 0; jdx < BUFFER_SIZE; jdx++)
    {
        if (count[jdx] > maxCount)
        {
            maxCount = count[jdx];
            mostFreqChar = jdx;
        }
    }
    return mostFreqChar;
}

int main()
{
    char str[] = "hello world";
    char mostFreqChar = findMostFreqChar(str);

    printf("出现频率最高的字符是：%c\n", mostFreqChar);

    return 0;

}